************************
* B. Kal Munis         *
* UVa Dept. of Politics*
* kalmunis@live.com    *
************************

* PARTIAL REPLICATION CODE (see other code for other parts of analysis) for: Us Over Here Versus Them Over There...Literally: Measuring Place Resentment in American Politics

clear all
cd "your-path-here"

use "replication_data_1.dta "

*******************************************************************************
*******************************************************************************
*******************************************************************************
*                            LUCID DATA 
*******************************************************************************
*******************************************************************************
*******************************************************************************

******************************************************
******************************************************
**           Factor Analysis, Alpha, Etc.           **
******************************************************
******************************************************

***************************
* PRINCIPLE AXIS FACTOR
****************************

***********
* factor analysis
factortest cultural_1 cultural_2 cultural_3 cultural_4 distributional_1 distributional_2 distributional_3 distributional_4 representational_3 representational_4

factor cultural_1 cultural_2 cultural_3 cultural_4 distributional_1 distributional_2 distributional_3 distributional_4 representational_3 representational_4, ipf factor(1) 
screeplot, yline(1)
rotate, promax normalize
sortl
 
*alpha reliability 
alpha cultural_1 cultural_2 cultural_3 cultural_4 distributional_1 distributional_2 distributional_3 distributional_4 representational_3 representational_4, std

***********************************

***************************
* PRINCIPLE COMPONENTS FACTOR
****************************

factortest cultural_1-distributional_4

factor cultural_1-distributional_4, pcf
rotate, promax blanks(.3)
sortl

* alpha of 4 item
alpha distributional_1 distributional_2 distributional_3 representational_4, std

******************************
******************************
* ANOVA

anova consciousness_full_nrm place_percep
pwcompare i.place_percep, mcompare(tukey) effects

*********************************************
*********************************************
*********************************************
*********************************************
*********************************************
*********************************************
* REGRESSION ANALYSES
*********************************************
*********************************************
*********************************************
*********************************************
*********************************************
*********************************************
clear all
cd "C:\Users\kalmu\OneDrive\Dissertation\Data\PICS Chapter 3"
set scheme s1mono
use "final_clean.dta"

***************************
* Urbanites feeling therm
***************************
*urban.. not sig (no evidence in-group bias)
reg ft_urbanites cces_consciousness_nrm identity_nrm racial_resentment_nrm populism_nrm ideo_polarization_nrm pid3 education age male i.region hhi white if rural==0, robust
*without identity_nrm
reg ft_urbanites cces_consciousness_nrm racial_resentment_nrm populism_nrm ideo_polarization_nrm pid3 education age male i.region hhi white if rural==0, robust

*rural sig neg (out-group bias)
reg ft_urbanites cces_consciousness_nrm identity_nrm racial_resentment_nrm populism_nrm ideo_polarization_nrm pid3 education age male i.region hhi white if rural==1, robust
*without identity_nrm
reg ft_urbanites cces_consciousness_nrm racial_resentment_nrm populism_nrm ideo_polarization_nrm pid3 education age male i.region hhi white if rural==1, robust


************************
*Ruralites feeling therm
************************
*urban.. sig neg (out-group bias)
reg ft_ruralites cces_consciousness_nrm identity_nrm racial_resentment_nrm populism_nrm ideo_polarization_nrm pid3 education age male i.region hhi white if rural==0, robust
*without identity_nrm
reg ft_ruralites cces_consciousness_nrm racial_resentment_nrm populism_nrm ideo_polarization_nrm pid3 education age male i.region hhi white if rural==0, robust

*rural not sig  ... no evidence of in-group bias
reg ft_ruralites cces_consciousness_nrm identity_nrm racial_resentment_nrm populism_nrm ideo_polarization_nrm pid3 education age male i.region hhi white if rural==1, robust
*without identity_nrm
reg ft_ruralites cces_consciousness_nrm racial_resentment_nrm populism_nrm ideo_polarization_nrm pid3 education age male i.region hhi white if rural==1, robust

**************************
* Suburbanites feeling therm
**************************
*urban.. sig neg (out-group bias)
reg ft_suburbanites cces_consciousness_nrm identity_nrm racial_resentment_nrm populism_nrm ideo_polarization_nrm pid3 education age male i.region hhi white if rural==0, robust

*rural not sig  ... no evidence of out-group bias
reg ft_suburbanites cces_consciousness_nrm identity_nrm racial_resentment_nrm populism_nrm ideo_polarization_nrm pid3 education age male i.region hhi white if rural==1, robust

************************************************
************************************************
************************************************
* WHO ARE THE GEOGRAPHICALLY RESENTFUL?
* Predicting place resentment
gen college_bin = .
replace college_bin = 1 if education > 4
replace college_bin = 0 if education < 5

reg consciousness_full_nrm identity_nrm racial_resentment_nrm i.pid3 college_bin age male i.region hhi i.place_percep white, robust

*for rural
reg consciousness_full_nrm identity_nrm racial_resentment_nrm  i.pid3 college_bin age male i.region hhi i.place_percep white if rural==1, robust

*for urban
reg consciousness_full_nrm identity_nrm racial_resentment_nrm i.pid3 college_bin age male i.region hhi i.place_percep white if rural==0, robust


*******************************************************************************
*******************************************************************************
*******************************************************************************
*                            CCES DATA 
*******************************************************************************
*******************************************************************************
*******************************************************************************
clear all
cd "your path here"

set scheme s1manual
use replication_data_2.dta 

***********
***********
* ANOVA
anova cces1 place3
pwcompare i.place3, mcompare(tukey) effects


*************
* Predicting place resentment
*************
*entire sample
reg cces1 rr ideo5 i.pid3 male college age i.region white hheconchange i.place3 [pweight=team] 

*urban
reg cces1 rr ideo5 i.pid3 male college age i.region white hheconchange [pweight=team] if place3==1 

*suburban
reg cces1 rr ideo5 ib3.pid3 male college age i.region white hheconchange [pweight=team] if place3==2

*rural
reg cces1 rr ideo5 i.pid3 male college age i.region white hheconchange [pweight=team] if place3==3   